package cn.wolfcode.luowowo2.common.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Albert on 2019/7/5.
 */
public class AssertUtil {
    /**
     * @param value 验证值
     * @param msg   错误信息
     */
    public static void hasLength(String value, String msg) {
        if (value == null || "".equals(value.trim())) {
            throw new DisableExeption(msg);
        }
    }

    public static void isEquals(String v1, String v2, String msg){
        if(v1==null || v2==null){
            throw new DisableExeption("传入参数不能为空");
        }

        if (!v1.equals(v2)) {  //这里记得加入!
            throw new DisableExeption(msg);
        }
    }

    public static void isPhoneNumber(String phone){
        Pattern pattern = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$");
        Matcher matcher = pattern.matcher(phone);
        if(!matcher.matches()){
            throw new DisableExeption("非手机号");
        }

    }

}
